﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;

namespace MusicExplorer.Tools
{
    public static class Net
    {
        public static string GetPartialWebPageContent(string url, int byteToLoads)
        {
            var result = string.Empty;
            HttpWebRequest request;
            request = WebRequest.Create(url) as HttpWebRequest;

            //get first 1000 bytes
            request.UseDefaultCredentials = true;
            request.AllowReadStreamBuffering = true;
            request.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), request);

            // the following code is alternative, you may implement the function after your needs
            //using (WebResponse response = request.GetResponse())
            //{
            //    using (Stream stream = response.GetResponseStream())
            //    {
            //        byte[] buffer = new byte[1024];
            //        int read = stream.Read(buffer, 0, 1000);
            //        Array.Resize(ref buffer, read);
            //        return Encoding.ASCII.GetString(buffer);
            //    }

            //}

            return null;
        }

        private static void GetRequestStreamCallback(IAsyncResult asynchronousResult)
        {

        }
    }
}
